/***************************************************************************
 *   Copyright (C) 2008 by Ryszard Król   *
 *   rysiek.krol@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/


#ifndef PICTUREMANAGER_H
#define PICTUREMANAGER_H

#include <QMainWindow>
#include <QCloseEvent>
#include <QEvent>
#include <QList>
#include <QFileInfo>
#include "property.h"


class QAction;
class QMenu;
class QListWidget;
class QListWidgetItem;
class QDir;
class QModelIndex;
class ImageReader;
class QTreeView;
class QSplitter;
class QStyle;
class QFileInfo;
class QScrollArea;
class ImageLoader;
class QLabel;
class QComboBox;
class FileOperationsHandler;
class ProgressBarDialogs;

class PictureManager:public QMainWindow
{
        Q_OBJECT

public:


        PictureManager(QStyle *styl);
        PictureManager(QStyle *styl, QString filePath);
        ~PictureManager();
        QListWidget *getListWidget();
        void setStyl(QStyle  *theValue);
        QStyle * getStyl();
        QLabel* getPresentationWidget() const;
        void setIsPresentationMode(bool theValue);
        bool getIsPresentationMode() const;
        Property* getItsProperty() const;

        QDir* getCurDir() const;

	ImageReader* getItsReader() const;
	void displayImage(QPixmap pixmap);


public slots:
void reLoadBrowserSlot();


protected:
        void keyPressEvent(QKeyEvent * event);
        void resizeEvent( QResizeEvent * event );
        void mousePressEvent( QMouseEvent * event );
        void wheelEvent ( QWheelEvent * event );

private slots:
        void listClicked ( QListWidgetItem * item );
        void about();
        void renameDialog();
        void treeClicked ( const QModelIndex & index );
        void switchGuiToBrowserMode();
        void displayNextImage();
        void displayCorrectImage();
        void displayPreviousImage();
        void goBackSlot();
        void goUpSlot();
        void fullScreenSwichSlot();
        void editComment();
        void removeCommentSlot();
        void closeEvent(QCloseEvent * event );
        void PropertyDialogOpenSlot();
        void sortingMethodChangedSlot(int index);
        void deleteFilesSlot();
        void copyFilesSlot();
        void moveFilesSlot();
        void makeDirectorySlot();

private:
        void createActions();
        void createMenus();
        void createToolBars();
        void createStatusBar();
        void customEvent ( QEvent *event );
        void contextMenuEvent ( QContextMenuEvent *event );
        void buildBrowserWidget();
        void switchGuiToPresentationMode(QFileInfo *fileInfo);
        void displayNextImage(bool reloadLoader);
        
        int findItem(QFileInfo *fileInfo);
        void loadImage(int index);
        void initializeGUI(QStyle * styl);
        QList<QFileInfo> fillFileList();

        QStyle *styl;
        ProgressBarDialogs *progressBarDialogs;
        FileOperationsHandler *itsFileoperationsHandler;
        ImageReader *itsReader;
        ImageLoader *itsLoader;
        QListWidget *listWidget;
        QTreeView *treeWidget;
        QSplitter *browserWidget;
        QLabel *presentationWidget;
        QScrollArea *scrollArea;
        QComboBox *sortingCombo;

        Property *itsProperty;
        QDir *curDir;
        QDir *oldDir;
        QMenu *fileMenu;
        QMenu *editMenu;
        QMenu *helpMenu;
        QMenu *contextMenu;
        QToolBar *browserToolBar;
        QToolBar *presentationToolBar;
        QToolBar *sortingToolBar;
        bool fullScreen;
        bool isPresentationMode;

        QAction *renameAct;
        QAction *exitAct;
        QAction *aboutAct;
        QAction *aboutQtAct;
        QAction *closePresentaionAct;
        QAction *displayNextImageAct;
        QAction *displayPreviousImageAct;
        QAction *goBackAct;
        QAction *goUpAct;
        QAction *reLoadBrowserAct;
        QAction *goToFullScreenAct;
        QAction *commentEditAct;
        QAction *commentRemoveAct;
        QAction *PropertyDialogOpenAct;
        QAction *sortingMethodChangedAct;
        QAction *removeFilesAct;
        QAction *copyFilesAct;
        QAction *moveFilesAct;
        QAction *makeDirectoryAct;
};

#endif
